package cn.tedu.store.config.tengxun;//package cn.tedu.store.config.tengxun;
//
//
//import com.alibaba.fastjson.JSONObject;
//
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.net.URL;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author Abell
// * @descibe 根据经纬度查询地址信息
// * @date 2020/6/20 11:04
// */
//public class JingWeiUtil {
//    /**
//     * 通过腾讯地图将经纬度转成详细地址
//     *
//     * @param lat 纬度
//     * @param lng 经度
//     * @return
//     *  http://api.map.baidu.com/geocoding/v3/?address=ADDRESS&output=json&ak=MYAK
//     */
//
//
//    //将获取到的位置信息转换为经纬度
//    public static Map<String, Object> getURLContent(String address) {
//        //这里需要使用你的key值
//        String urlStr = "https://apis.map.qq.com/ws/geocoder/v1/?address=" + address + "&key=HCVBZ-WP6KD-RSL4P-PK3DW-2JR4Z-NLFC5";
//        //请求的url
//        URL url = null;
//        //请求的输入流
//        BufferedReader in = null;
//        //输入流的缓冲
//        StringBuffer sb = new StringBuffer();
//        try {
//            url = new URL(urlStr);
//            in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
//            String str = null;
//            //一行一行进行读入
//            while ((str = in.readLine()) != null) {
//                sb.append(str);
//            }
//        } catch (Exception ex) {
//
//        } finally {
//            try {
//                if (in != null) {
//                    in.close(); //关闭流
//                }
//            } catch (IOException ex) {
//
//            }
//        }
//        String result = sb.toString();
//        String r = JSONObject.fromObject(result).getString("result");
//        String location = JSONObject.fromObject(r).getString("location");
//        String lng = JSONObject.fromObject(location).getString("lng");
//        String lat = JSONObject.fromObject(location).getString("lat");
//        Map<String, Object> map = new HashMap<>();
//        map.put("lng", lng);
//        map.put("lat", lat);
//        return map;
//    }
//
////    public static void main(String[] args) {
////
////    }
//
//
//
//
////    public static JSONObject getLatAndLng(String lat, String lng, String key) {
////        try {
////            String hsUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location="+lat+","+lng+"&key="+key+"&get_poi=1";
////
////            URL url;
////
////            url = new URL(hsUrl);
////            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
////            con.setRequestMethod("GET");// 提交模式
////            X509TrustManager xtm = new X509TrustManager() {
////                @Override
////                public X509Certificate[] getAcceptedIssuers() {
////                    // TODO Auto-generated method stub
////                    return null;
////                }
////
////                @Override
////                public void checkServerTrusted(X509Certificate[] arg0, String arg1)
////                        throws CertificateException {
////                    // TODO Auto-generated method stub
////
////                }
////
////                @Override
////                public void checkClientTrusted(X509Certificate[] arg0, String arg1)
////                        throws CertificateException {
////                    // TODO Auto-generated method stub
////
////                }
////            };
////
////            TrustManager[] tm = {xtm};
////
////            SSLContext ctx = SSLContext.getInstance("TLS");
////            ctx.init(null, tm, null);
////
////            con.setSSLSocketFactory(ctx.getSocketFactory());
////            con.setHostnameVerifier(new HostnameVerifier() {
////                @Override
////                public boolean verify(String arg0, SSLSession arg1) {
////                    return true;
////                }
////            });
////
////
////            InputStream inStream = con.getInputStream();
////            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
////            byte[] buffer = new byte[1024];
////            int len = 0;
////            while ((len = inStream.read(buffer)) != -1) {
////                outStream.write(buffer, 0, len);
////            }
////            byte[] b = outStream.toByteArray();//网页的二进制数据
////            outStream.close();
////            inStream.close();
////            String rtn = new String(b, "utf-8");
////            if (StringUtils.isNotBlank(rtn)) {
////                JSONObject object = JSONObject.fromObject(rtn);
////                if (object != null) {
////                    if (object.has("status") && object.getInt("status") == 0) {
////                        JSONObject result = JSONObject.fromObject(object.get("result"));
////                        if (result != null) {
////                            JSONObject addressComponent = JSONObject.fromObject(result.get("address_component"));
////                            if (addressComponent != null) {
////                                return addressComponent;
////                            }
////                        }
////                    }
////                }
////            }
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
////        return null;
////    }
////    public static void main(String[] args) {
////        Map<String, Object> map = getURLContent("湖北省宜昌市枝江市枝江人民医院");
////        System.out.println("lng=" + map.get("lng") + ",lat=" + map.get("lat"));
////    }
//
//
//
//
//
//
//
//
//}
//
